﻿@{
    //page title
    ViewBag.Title = Loc["Admin.Configuration.Payment.Methods"];
}

<div class="row">
    <div class="col-md-12">
        <div class="x_panel light form-fit">
            <div class="x_title">
                <div class="caption level-caption">
                    <i class="fa fa-money"></i>
                    @Loc["Admin.Configuration.Payment.Methods"]
                </div>
            </div>
            <div class="x_content">
                <div class="form-horizontal">
                    <div class="form-body">
                        @await Component.InvokeAsync("StoreScope")
                    </div>
                </div>
            </div>
            <div class="x_content form">
                <vc:admin-widget widget-zone="payment_method_list_top" additional-data="Model"/>
                <div id="paymentmethods-grid"></div>
                <vc:admin-widget widget-zone="payment_method_list_bottom" additional-data="Model"/>
            </div>
        </div>
    </div>
</div>
<script>
    $(document).ready(function () {
        $("#paymentmethods-grid").kendoGrid({
            dataSource: {
                transport: {
                    read: {
                        url: "@Html.Raw(Url.Action("Methods", "Payment", new { area = Constants.AreaAdmin }))",
                        type: "POST",
                        dataType: "json",
                        data: addAntiForgeryToken
                    },
                    update: {
                        url: "@Html.Raw(Url.Action("MethodUpdate", "Payment", new { area = Constants.AreaAdmin }))",
                        type: "POST",
                        dataType: "json",
                        data: addAntiForgeryToken
                    }
                },
                schema: {
                    data: "Data",
                    total: "Total",
                    errors: "Errors",
                    model: {
                        id: "SystemName",
                        fields: {
                            FriendlyName: { editable: false, type: "string" },
                            SystemName: { editable: false, type: "string" },
                            LogoUrl: { editable: false, type: "string" },
                            SupportCapture: { editable: false, type: "boolean" },
                            SupportRefund: { editable: false, type: "boolean" },
                            SupportPartiallyRefund: { editable: false, type: "boolean" },
                            SupportVoid: { editable: false, type: "boolean" },
                            DisplayOrder: { editable: false, type: "number" },
                            IsActive: { editable: true, type: "boolean" }
                        }
                    }
                },
                requestEnd: function (e) {
                    if (e.type == "update") {
                        this.read();
                    }
                },
                error: function (e) {
                    display_kendoui_grid_error(e);
                    // Cancel the changes
                    this.cancelChanges();
                },
                serverPaging: true,
                serverFiltering: true,
                serverSorting: true
            },
            pageable: {
                refresh: true,
                numeric: false,
                previousNext: false,
                info: false
            },
            editable: {
                confirmation: false,
                mode: "inline"
            },
            scrollable: false,
            columns: [{
                field: "FriendlyName",
                title: "@Loc["Admin.Configuration.Payment.Methods.Fields.FriendlyName"]",
                template: '<a class="k-link" href="#=ConfigurationUrl#">#=FriendlyName#</a>',
            }, {
                field: "SystemName",
                title: "@Loc["Admin.Configuration.Payment.Methods.Fields.SystemName"]",
                template: '<a class="k-link" href="#=ConfigurationUrl#">#=SystemName#</a>',
            }, {
                field: "SupportCapture",
                title: "@Loc["Admin.Configuration.Payment.Methods.Fields.SupportCapture"]",
                headerAttributes: { style: "text-align:center" },
                attributes: { style: "text-align:center" },
                template: '# if(SupportCapture) {# <i class="fa fa-check" aria-hidden="true" style="color:green"></i> #} else {# <i class="fa fa-times" aria-hidden="true" style="color:red"></i> #} #'
            }, {
                field: "SupportRefund",
                title: "@Loc["Admin.Configuration.Payment.Methods.Fields.SupportRefund"]",
                headerAttributes: { style: "text-align:center" },
                attributes: { style: "text-align:center" },
                template: '# if(SupportRefund) {# <i class="fa fa-check" aria-hidden="true" style="color:green"></i> #} else {# <i class="fa fa-times" aria-hidden="true" style="color:red"></i> #} #'
            }, {
                field: "SupportPartiallyRefund",
                title: "@Loc["Admin.Configuration.Payment.Methods.Fields.SupportPartiallyRefund"]",
                headerAttributes: { style: "text-align:center" },
                attributes: { style: "text-align:center" },
                template: '# if(SupportPartiallyRefund) {# <i class="fa fa-check" aria-hidden="true" style="color:green"></i> #} else {# <i class="fa fa-times" aria-hidden="true" style="color:red"></i> #} #'
            }, {
                field: "SupportVoid",
                title: "@Loc["Admin.Configuration.Payment.Methods.Fields.SupportVoid"]",
                headerAttributes: { style: "text-align:center" },
                attributes: { style: "text-align:center" },
                template: '# if(SupportVoid) {# <i class="fa fa-check" aria-hidden="true" style="color:green"></i> #} else {# <i class="fa fa-times" aria-hidden="true" style="color:red"></i> #} #'
            }, 
            {
                field: "DisplayOrder",
                title: "@Loc["Admin.Configuration.Payment.Methods.Fields.DisplayOrder"]",
                format: "{0:0}",
            }, {
                field: "IsActive",
                title: "@Loc["Admin.Configuration.Payment.Methods.Fields.IsActive"]",
                headerAttributes: { style: "text-align:center" },
                attributes: { style: "text-align:center" },
                template: '# if(IsActive) {# <i class="fa fa-check" aria-hidden="true" style="color:green"></i> #} else {# <i class="fa fa-times" aria-hidden="true" style="color:red"></i> #} #'
            }, {
                command: {
                    name: "edit",
                    text: {
                        edit: "@Loc["Admin.Common.Edit"]",
                        update: "@Loc["Admin.Common.Update"]",
                        cancel: "@Loc["Admin.Common.Cancel"]"
                    }
                },
                title: "@Loc["Admin.Common.Edit"]",
                width: 150
            }]
        });
    });
</script>